import 'package:flutter/material.dart';
import 'package:fluro/fluro.dart';
import 'package:hospitable_rental/pages/home/index.dart';
import 'package:hospitable_rental/pages/home/profile/setting/index.dart';
import 'package:hospitable_rental/pages/not_found.dart';
import 'package:hospitable_rental/pages/room/detail/index.dart';
import 'package:hospitable_rental/pages/room/manage/index.dart';
import 'package:hospitable_rental/pages/room/publish/index.dart';
import 'package:hospitable_rental/pages/user/login_page.dart';
import 'package:hospitable_rental/pages/user/register_page.dart';

// 2. 定义路由处理函数
/// 无效页面
var notFoundHandler = Handler(
  handlerFunc: (BuildContext? context, Map<String, List<String>> params) {
    print("ROUTE WAS NOT FOUND !!!");
    return NotFoundPage();
  },
);

/// 首页
var homeHandler = Handler(
  handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
    return HomePage();
  },
);

/// 登录
var loginHandler = Handler(
  handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
    return LoginPage();
  },
);

var registerHandler = Handler(
  handlerFunc: (BuildContext? context, Map<String, List<String>> parameters) {
    return RegisterPage();
  },
);

/// 房间详情
var roomDetailHandler = Handler(
  handlerFunc: (BuildContext? context, Map<String, dynamic> parameters) {
    print(parameters);
    String? roomId = parameters["roomId"]?.first;
    return RoomDetailPage(roomId: roomId);
  },
);

var settingHandler = Handler(
  handlerFunc: (BuildContext? context, Map<String, dynamic> params) {
    return SettingPage();
  },
);

var roomsManageHandler = Handler(
  handlerFunc: (BuildContext? context, Map<String, dynamic> params) {
    return RoomsManagePage();
  },
);

var roomPublishHandler = Handler(
  handlerFunc: (BuildContext? context, Map<String, dynamic> params) {
    return RoomPublishPage();
  },
);
